<template>
  <div class="header flex-h">
    <div @click="goback" class="left">
      <i class="imgIcon"></i>
    </div>
    <h2 class="flex1">{{contentTitle}}</h2>
    <div class="right">
      <span v-if="rightText" @click="goto(jumpRoute)">{{rightText}}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    rightText: String,
    jumpRoute: String,
    contentTitle: String,
    right: {
      type: Boolean,
      default: true
    },
    backApp: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    goback() {
      if (this.backApp) {
        if (this.commonJs.checkTerminal() === "ios") {
          window.webkit.messageHandlers.backMessage.postMessage("back");
        } else if (this.commonJs.checkTerminal() === "android") {
          ZMParentsJsToAndroid.backMessage("back");
        } else {
          this.$router.back();
        }
      } else {
        this.$router.back();
      }
    },
    goto(routerName, queryData) {
      this.$router.push({
        path: routerName,
        query: {
          type: queryData
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
.header {
  z-index: 2;
  position: relative;
  width: 100%;
  height: 0.88rem;
  // text-align: right;
  padding: 0 0.32rem;
  background: #fff;
  font-size: 0.3rem;
  letter-spacing: 0.05rem;
  color: #222;
  font-weight: bold;
  // display: flex;
  // justify-content: space-between;
  // align-items: center;
  .left,
  .right {
    width: 2rem;
    height: 0.88rem;
  }
  .right {
    line-height: 0.88rem;
  }
  .left {
    .imgIcon{
      width: 0.4rem;
      height: 0.4rem;
      margin-top: 0.22rem;
      display: inline-block;
      background: url('~@/static/sprite/icon_sprites_40.png') -0.1rem -0.1rem;
			background-size:3rem 2.4rem; 
    }
  }

  h2 {
    font-size: 0.36rem;
    font-weight: bold;
    text-align: center;
  }
}
</style>

